/**
 * 表单自定义控制器
 */
app.controller('btnCtrl', ['$scope', '$http', BtnController]);
function BtnController($scope, $http) {
	$scope.bindBtn = function(event) {
		switch(event){
			case 'event-to-add': // 新增工资付款单
			{
				$scope.showModalRadio('TB_UserPayApplyGz',3, "id",null);
				break;
			}
			case 'event-to-delete': // 删除选中数据
			{
				$scope.subGrid.deleteBatch();
				break;
			}
		};
	}

}

/*
 * 自定义通用控制器，若无定义，页面会报错
 */
app.controller('formSelfCtrl', ['$scope', '$http', function FormSelfController($scope, $http) {

	//单选回调
	$scope.doSelectRadioBySelf = function (rowSelected) {
		$http.post('/api/inter/tbUserPayApply/searchGzXq', {}, {params: {pid: rowSelected.id}})
			.success(function (data) {
					if (data.code == 0) {
						$scope.subGrid.sonlist = data.data
						if (data.data.length != 0) {
							var realityPaySlip = 0;
							for (let i = 0; i < data.data.length; i++) {
								realityPaySlip = realityPaySlip + Number(data.data[i].realityPaySlip)
							}
							$scope.valueMap['userPayApplyBid'] = rowSelected.bid;
							$scope.valueMap['orgName'] = rowSelected.orgName;
							$scope.valueMap['userPayApplyid'] = rowSelected.id;
							$scope.valueMap['realityPaySlip'] = realityPaySlip;
						}
					} else {
						alert(data.msg);
					}
				}
			);
	}
}
]);



